﻿using System;
using System.Collections.Generic;
using VideoStore.Services.Translation.Base;

namespace VideoStore.Services.Translation.Factory
{
    /// <summary>
    /// Provides access to the business to DTO translators.
    /// </summary>
    public class TranslatorFactory
    {
        private static readonly Dictionary<Type, ITranslator> translators = new Dictionary<Type, ITranslator>();

        /// <summary>
        /// Initializes a new instance of the <see cref="TranslatorFactory"/> class.
        /// </summary>
        static TranslatorFactory()
        {
            translators.Add(typeof(CustomerTranslator), new CustomerTranslator());
            translators.Add(typeof(CatalogueTranslator), new CatalogueTranslator());
            translators.Add(typeof(OrderTranslator), new OrderTranslator());
            translators.Add(typeof(StockTranslator), new StockTranslator());
            translators.Add(typeof(StoreTranslator), new StoreTranslator());
            translators.Add(typeof(WarehouseTranslator), new WarehouseTranslator());
        }

        /// <summary>
        /// Gets a business translator by type.
        /// </summary>
        /// <param name="translatorType">Type of the translator.</param>
        /// <returns></returns>
        public static ITranslator GetTranslatorByType(Type translatorType)
        {
            if (translators.ContainsKey(translatorType))
            {
                return translators[translatorType];
            }
            return null;
        }
    }
}